package com.ws.shop.action.front;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.ws.shop.bean.Page;
import com.ws.shop.common.CommonData;
import com.ws.shop.entity.Member;
import com.ws.shop.service.MessageService;
import com.ws.shop.util.RequestUtil;

@Controller
@RequestMapping(value = "/message/*")
public class MessageAction  extends BaseFrontAction {
	@Autowired
    private MessageService messageService;
	
	//会员中心的我的反馈列表
	@RequestMapping(value="myMessage.htm",method=RequestMethod.GET)//请求地址
	public String myMessage(HttpServletRequest request,Model model){
		Map<String,Object> loginMember = getLoginMember(request.getSession(false));
		int pageno = RequestUtil.getIntParameter(request, Page.PAGE_NO, 1);
		Page page = new Page(pageno,10);
		int state = 1;
		messageService.getMessageByUid(page, state, (Integer)loginMember.get(Member.LOGIN_MEMBER_ID_KEY));
		model.addAttribute("page", page);
		return "myMessage";
	}
	
	//前台意见反馈
	@RequestMapping(value="messageindex.htm",method=RequestMethod.GET)//请求地址
	public String messageindex(HttpServletRequest request,Model model){
		int pageno = RequestUtil.getIntParameter(request, Page.PAGE_NO, 1);
		Page page = new Page(pageno,10);
		int state = 1;
		messageService.getMessages(page, state);
		model.addAttribute("page", page);
		model.addAttribute("feedbackStatus", CommonData.FEEDBACK_MESSAGE_STATUS);
		return "messageindex";
	}
	
}
